#define _CRT_SECURE_NO_WARNINGS 1
#include "list.h"

void List_Test1()
{
	wjq::list<int> l1;
	l1.push_back(1);
	l1.push_back(2);
	l1.push_back(3);
	l1.push_back(4);
	l1.push_back(5);

	const wjq::list<int> l2 = l1;
	wjq::list<int>::const_iterator it = l2.begin();
	while (it != l2.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

	/*while (it != l1.end())
	{
		*it *= 2;
		cout << *it << " ";
		++it;
	}
	cout << endl;*/
}

void List_Test2()
{
	wjq::list<int> l1;
	l1.push_back(1);
	l1.push_back(2);
	l1.push_back(3);
	l1.push_back(4);
	l1.push_back(5);

	wjq::list<int>::iterator it1 = l1.begin();

	wjq::list<string> l2;
	l2.push_back("hello");
	l2.push_back(" ");
	l2.push_back("world");

	wjq::list<string>::iterator it2 = l2.begin();
	it2->_data = "xxx";
}

void List_Test3()
{
	wjq::list<int> l1;
	l1.push_back(1);
	l1.push_back(2);
	l1.push_back(3);
	l1.push_back(4);
	l1.push_back(5);

	l1.insert(l1.begin(), 30);
	l1.insert(l1.begin(), 30);

	l1.insert(l1.end(), 30);

	wjq::list<int>::iterator it = l1.begin();
	while (it != l1.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

	l1.push_back(1100);
	l1.push_front(1100);

	it = l1.begin();
	while (it != l1.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

	l1.erase(l1.begin());
	l1.pop_back();
	l1.pop_front();

	it = l1.begin();
	while (it != l1.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;
}

void List_Test4()
{
	wjq::list<int> l1;
	l1.push_back(1);
	l1.push_back(2);
	l1.push_back(3);
	l1.push_back(4);
	l1.push_back(5);

	wjq::list<int> l2(l1);
	for (auto e : l2)
	{
		cout << e << " ";
	}
	cout << endl;

	wjq::list<int> l3;
	l3 = l2;
	for (auto e : l2)
	{
		cout << e << " ";
	}
	cout << endl;
}

void List_Test5()
{
	wjq::list<int> l1;
	l1.push_back(1);
	l1.push_back(2);
	l1.push_back(3);
	l1.push_back(4);
	l1.push_back(5);

	const wjq::list<int> l2(l1);

	wjq::list<int>::const_iterator it2 = l2.begin();

	/*while(it2 != l2.end())
	{
		(*it2)++;
		cout << *it2 << " ";
		it2++;
	}
	cout << endl;*/
}

void List_Test6()
{
	wjq::list<int> l1;
	l1.push_back(1);
	l1.push_back(2);
	l1.push_back(3);
	l1.push_back(4);
	l1.push_back(5);

	wjq::list<int>::iterator it = l1.begin();
	while (it != l1.end())
	{
		cout << *it << " ";
		it++;
	}
	cout << endl;

	wjq::list<int>::reverse_iterator rit = l1.rbegin();
	while (rit != l1.rend())
	{
		cout << *rit << " ";
		rit++;
	}
	cout << endl;
}

int main()
{
	List_Test6();
	return 0;
}